<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Essay Helper</title>
    <link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
</head>
<body>
    <div class="container">
        <header>
            <h1><i class="fas fa-book-reader"></i> Essay Helper</h1>
            <p>Upload your PDF to extract unfamiliar words or convert to audio</p>
            
            <div class="auth-nav">
                {% if current_user.is_authenticated %}
                <a href="{{ url_for('dashboard') }}" class="user-link">
                    <i class="fas fa-user-circle"></i> {{ current_user.username }}
                </a>
                <a href="{{ url_for('logout') }}" class="logout-link">
                    <i class="fas fa-sign-out-alt"></i> 登出
                </a>
                {% else %}
                <a href="{{ url_for('login') }}" class="auth-link">
                    <i class="fas fa-sign-in-alt"></i> 登录
                </a>
                <a href="{{ url_for('register') }}" class="auth-link register">
                    <i class="fas fa-user-plus"></i> 注册
                </a>
                {% endif %}
            </div>
        </header>
        
        {% with messages = get_flashed_messages(with_categories=true) %}
            {% if messages %}
                {% for category, message in messages %}
                    <div class="flash-message {{ category }}">
                        {% if category == 'error' %}
                            <i class="fas fa-exclamation-circle"></i>
                        {% else %}
                            <i class="fas fa-check-circle"></i>
                        {% endif %}
                        {{ message }}
                    </div>
                {% endfor %}
            {% endif %}
        {% endwith %}
        
        <div class="tabs">
            <button class="tab-btn active" data-tab="extract"><i class="fas fa-font"></i> Extract Words</button>
            <button class="tab-btn" data-tab="audio"><i class="fas fa-headphones"></i> Convert to Audio</button>
        </div>
        
        <div class="tab-content">
            <div id="extract" class="tab-pane active">
                <form id="extract-form" class="upload-form">
                    <div class="file-upload">
                        <input type="file" id="extract-file" name="file" accept=".pdf" required>
                        <label for="extract-file"><i class="fas fa-file-pdf"></i> Choose PDF file</label>
                    </div>
                    <button type="submit" class="submit-btn"><i class="fas fa-search"></i> Extract Words</button>
                    <div id="extract-progress" class="progress-container hidden">
                        <div class="progress-bar"></div>
                        <div class="progress-text">Processing...</div>
                    </div>
                </form>
                
                <div id="word-results" class="results">
                    <div class="results-header">
                        <h2><i class="fas fa-lightbulb"></i> Unfamiliar Words</h2>
                        <button id="download-words-btn" class="action-btn hidden"><i class="fas fa-download"></i> Download Words</button>
                    </div>
                    <div class="loading-spinner hidden"></div>
                    <ul id="word-list"></ul>
                </div>
            </div>
            
            <div id="audio" class="tab-pane">
                <form id="audio-form" class="upload-form">
                    <div class="file-upload">
                        <input type="file" id="audio-file" name="file" accept=".pdf" required>
                        <label for="audio-file"><i class="fas fa-file-pdf"></i> Choose PDF file</label>
                    </div>
                    <button type="submit" class="submit-btn"><i class="fas fa-volume-up"></i> Convert to Audio</button>
                    <div id="audio-progress" class="progress-container hidden">
                        <div class="progress-bar"></div>
                        <div class="progress-text">Converting...</div>
                    </div>
                </form>
                
                <div id="audio-results" class="results">
                    <h2><i class="fas fa-music"></i> Audio Conversion</h2>
                    <div class="loading-spinner hidden"></div>
                    <div id="audio-player" class="hidden">
                        <audio controls id="player"></audio>
                        <div class="audio-controls">
                            <button id="play-all-btn" class="action-btn"><i class="fas fa-play-circle"></i> Play All</button>
                            <a id="download-link" class="download-btn"><i class="fas fa-download"></i> Download Current</a>
                        </div>
                    </div>
                    <!-- Audio files list will be added here dynamically -->
                </div>
            </div>
        </div>
        
        <footer>
            <p><i class="fas fa-code"></i> PDF processing tools for students and researchers</p>
        </footer>
    </div>
    
    <script src="{{ url_for('static', filename='js/main.js') }}"></script>
</body>
</html> 